\(\int (a+b \cot ^2(c+d x)) \, dx\) [2]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [C] (verified)
   Fricas [B] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 12, antiderivative size = 20 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=a x-b x-\frac {b \cot (c+d x)}{d} \]

[Out]

a*x-b*x-b*cot(d*x+c)/d

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3554, 8} \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=a x-\frac {b \cot (c+d x)}{d}-b x \]

[In]

Int[a + b*Cot[c + d*x]^2,x]

[Out]

a*x - b*x - (b*Cot[c + d*x])/d

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3554

Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((b*Tan[c + d*x])^(n - 1)/(d*(n - 1))), x] - Dis
t[b^2, Int[(b*Tan[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1]

Rubi steps \begin{align*} \text {integral}& = a x+b \int \cot ^2(c+d x) \, dx \\ & = a x-\frac {b \cot (c+d x)}{d}-b \int 1 \, dx \\ & = a x-b x-\frac {b \cot (c+d x)}{d} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.02 (sec) , antiderivative size = 34, normalized size of antiderivative = 1.70 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=a x-\frac {b \cot (c+d x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(c+d x)\right )}{d} \]

[In]

Integrate[a + b*Cot[c + d*x]^2,x]

[Out]

a*x - (b*Cot[c + d*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[c + d*x]^2])/d

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 0.02 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.45

method result size
risch \(a x -b x -\frac {2 i b}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}\) \(29\)
norman \(\frac {\left (a -b \right ) x \tan \left (d x +c \right )-\frac {b}{d}}{\tan \left (d x +c \right )}\) \(30\)
parallelrisch \(\frac {b \left (-\tan \left (d x +c \right ) x d -1\right )}{d \tan \left (d x +c \right )}+a x\) \(30\)
default \(a x +\frac {b \left (-\cot \left (d x +c \right )+\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )\right )}{d}\) \(31\)
parts \(a x +\frac {b \left (-\cot \left (d x +c \right )+\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )\right )}{d}\) \(31\)
derivativedivides \(\frac {-b \cot \left (d x +c \right )+\left (-a +b \right ) \left (\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )\right )}{d}\) \(34\)

[In]

int(a+b*cot(d*x+c)^2,x,method=_RETURNVERBOSE)

[Out]

a*x-b*x-2*I*b/d/(exp(2*I*(d*x+c))-1)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 48 vs. \(2 (20) = 40\).

Time = 0.31 (sec) , antiderivative size = 48, normalized size of antiderivative = 2.40 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=\frac {{\left (a - b\right )} d x \sin \left (2 \, d x + 2 \, c\right ) - b \cos \left (2 \, d x + 2 \, c\right ) - b}{d \sin \left (2 \, d x + 2 \, c\right )} \]

[In]

integrate(a+b*cot(d*x+c)^2,x, algorithm="fricas")

[Out]

((a - b)*d*x*sin(2*d*x + 2*c) - b*cos(2*d*x + 2*c) - b)/(d*sin(2*d*x + 2*c))

Sympy [A] (verification not implemented)

Time = 0.07 (sec) , antiderivative size = 22, normalized size of antiderivative = 1.10 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=a x + b \left (\begin {cases} - x - \frac {\cot {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \cot ^{2}{\left (c \right )} & \text {otherwise} \end {cases}\right ) \]

[In]

integrate(a+b*cot(d*x+c)**2,x)

[Out]

a*x + b*Piecewise((-x - cot(c + d*x)/d, Ne(d, 0)), (x*cot(c)**2, True))

Maxima [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 23, normalized size of antiderivative = 1.15 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=a x - \frac {{\left (d x + c + \frac {1}{\tan \left (d x + c\right )}\right )} b}{d} \]

[In]

integrate(a+b*cot(d*x+c)^2,x, algorithm="maxima")

[Out]

a*x - (d*x + c + 1/tan(d*x + c))*b/d

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 40, normalized size of antiderivative = 2.00 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=a x - \frac {{\left (2 \, d x + 2 \, c + \frac {1}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )} - \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )} b}{2 \, d} \]

[In]

integrate(a+b*cot(d*x+c)^2,x, algorithm="giac")

[Out]

a*x - 1/2*(2*d*x + 2*c + 1/tan(1/2*d*x + 1/2*c) - tan(1/2*d*x + 1/2*c))*b/d

Mupad [B] (verification not implemented)

Time = 13.25 (sec) , antiderivative size = 20, normalized size of antiderivative = 1.00 \[ \int \left (a+b \cot ^2(c+d x)\right ) \, dx=x\,\left (a-b\right )-\frac {b\,\mathrm {cot}\left (c+d\,x\right )}{d} \]

[In]

int(a + b*cot(c + d*x)^2,x)

[Out]

x*(a - b) - (b*cot(c + d*x))/d